package com.ny.service.impl;

import com.ny.dao.StudentDao;
import com.ny.dao.impl.StudentDaoImpl;
import com.ny.entity.Student;
import com.ny.service.StudentService;

import java.sql.SQLException;
import java.util.List;

public class StudentServiceImpl  implements StudentService {
    private StudentDao studentDao = new StudentDaoImpl();
    public StudentServiceImpl() throws SQLException, ClassNotFoundException {
    }
    @Override
    public int add(Student student) throws SQLException, ClassNotFoundException {
//        调用数据访问层的添加方法
        return studentDao.add(student);

    }

    @Override
    public Student login(String studentName, String studentPassword) throws SQLException {

        return studentDao.login(studentName,studentPassword);
    }

    @Override
    public Student findById(int studentId) throws SQLException {
        return studentDao.findById(studentId);
    }

    @Override
    public int updatePassword(int studentId, String studentPassword) throws SQLException {
        return studentDao.updatePassword(studentId,studentPassword);
    }

    @Override
    public int updatePhone(int studentId, String studentPhone) throws SQLException {
        return studentDao.updatePhone(studentId,studentPhone);
    }

    @Override
    public List<Student> findAllStudent() throws SQLException {
        return studentDao.findAllStudent();
    }

    @Override
    public int update(Student student) throws SQLException {
        return studentDao.update(student);
    }

    @Override
    public int delete(int studentId) throws SQLException {
        return studentDao.delete(studentId);
    }

}
